package tech.aistar.service;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tech.aistar.mapper.UserMapper;
import tech.aistar.pojo.User;

import java.util.List;
import java.util.UUID;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> getAll() {
        return userMapper.findAll();
    }

    @Override
    public User login(String username) {
        return userMapper.findByUsername(username);
    }

    @Override
    public int insertGUser(User user) {
        return 0;
    }


    @Override
    public List<User> findXinXi() {
        return userMapper.findXinXi();
    }

    @Override
    public int update(String username, String intro, String phone) {
        return  userMapper.update(username,intro,phone);
    }

    @Override
    public int updatePhoto(String uPhoto ,String phone) {
        return  userMapper.updatePhoto(uPhoto,phone);
    }

    @Override
    public void upvip(String vipname, int state, String startime, String endtime,int id) {
        userMapper.upvip(vipname,state,startime,endtime,id);
    }

    @Override
    public int selede(int uid) {
        return userMapper.selede(uid);
    }

    @Override
    public User register(String phone) {
        return userMapper.findByPhone(phone);
    }

    @Override
    public int insert(String phone, String password,String username) {
//      String  username = UUID.randomUUID().toString().replaceAll("-","").substring(0,10);

//        String password = Jwts.builder().claim("password","Yan611731")
//                .signWith(SignatureAlgorithm.HS256,YAN).compact();
        return userMapper.inset(phone,password,username);
    }
}
